#-*- coding: utf8 -*-
from tutor.scripts import *
from tutor.plugins.maple import *

# variáveis úteis
half = M('1/2')
t = M.t
_i, _j, _k = M('_i, _j, _k')
rr = M('`..`')
coeff = M.coeff
n_iter = 0
while True:
    with display_block('Entradas'):
        a = M(oneof(-2, -1, -1, 1, 1, 2, 3))
        b = M(oneof(-2, -1, 1, 1, 2, 3))
        c = M(oneof(-2, -1, 1, 1, 2, 3))
        d = M(oneof(-2, -1, 1, 1, 2, 3))
        A = fieldA = (b * x ** 2) * _i + \
                     (a * x * z + c * y ** 3) * _j + \
                     (d * z) * _k

    with display_block('Resultados'):
        n_iter += 1
        campoB = -a * x * _i + a * z * _k
        campoBS = -campoB
        campoB2 = a * x * _i + a * z * _k
        campoBS2 = -campoB2
        divergente = 2 * b * x * _i + 3 * c * y ** 2 * _j + d * _k
        divergenteS = -divergente

        fluxo = Pi * a
        fluxoGauss = c * Pi / 4
        fluxoGauss2 = b * Pi / 12 + d * Pi / 3

        distr1 = oneof(fluxo, fluxoGauss, fluxoGauss2) * oneof(-2, -1, 1, 2, 4) / M(oneof(-2, -1, 1, 2, 4))
        distr2 = oneof(fluxo, fluxoGauss, fluxoGauss2) * oneof(-2, -1, 1, 2, 4) / M(oneof(-2, -1, 1, 2, 4))

        if len(set([fluxo, fluxoGauss, fluxoGauss2, distr1, distr2, campoB, campoBS, campoB2, campoBS2, divergente, divergenteS])) == 11:
            break

